package com.jwgf.report;

import java.util.Calendar;

public class ShiftInfo {
	private int num;
	private Calendar time = Calendar.getInstance();
	
	public ShiftInfo(int num, int hour, int minute) {
		super();
		this.num = num;
		time.set(Calendar.HOUR_OF_DAY, hour);
		time.set(Calendar.MINUTE, minute);
		time.set(Calendar.SECOND, 0);
	}

	public ShiftInfo(int num, Calendar date) {
		this.num = num;
		time.setTimeInMillis(date.getTimeInMillis());
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public Calendar getTime() {
		return time;
	}

	public int getHour() {
		return time.get(Calendar.HOUR_OF_DAY);
	}

	public void setHour(int hour) {
		time.set(Calendar.HOUR_OF_DAY, hour);
	}

	public int getMinute() {
		return time.get(Calendar.MINUTE);
	}

	public void setMinute(int minute) {
		time.set(Calendar.MINUTE, minute);
	}

	public int getTotalMinutes() {
		return getHour() * 60 + getMinute();
	}

	@Override
	public String toString() {
		return num + "," + getHour() + "," + getMinute();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + num;
		result = prime * result + ((time == null) ? 0 : time.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ShiftInfo other = (ShiftInfo) obj;
		if (num != other.num)
			return false;
		if (time == null) {
			if (other.time != null)
				return false;
		} else if (!time.equals(other.time))
			return false;
		return true;
	}
}
